(function () {
    /**
     * @exports defined
     *
     * @param {Object} value The object.
     * @returns {Boolean} Returns true if the object is defined, returns false otherwise.
     *
     * @example
     * if (defined(positions)) {
     *      doSomething();
     * } else {
     *      doSomethingElse();
     * }
     */
    function defined(value) {
        return value !== undefined && value !== null;
    }

    /**
     * Returns the first parameter if not undefined, otherwise the second parameter.
     * Useful for setting a default value for a parameter.
     *
     * @exports defaultValue
     *
     * @param {*} a
     * @param {*} b
     * @returns {*} Returns the first parameter if not undefined, otherwise the second parameter.
     *
     * @example
     * param = Cesium.defaultValue(param, 'default');
     */
    function defaultValue(a, b) {
        if (a !== undefined && a !== null) {
            return a;
        }
        return b;
    }

    function setCachedGltf(model, cachedGltf) {
        model._cachedGltf = cachedGltf;
    }

    function CachedGltf(options) {
        this.gltf = options.gltf;
        this.ready = options.ready;
        this.modelsToLoad = [];
        this.count = 0;
    }

    CachedGltf.prototype.makeReady = function (gltfJson) {
        this.gltf = gltfJson;

        var models = this.modelsToLoad;
        var length = models.length;
        for (var i = 0; i < length; ++i) {
            var m = models[i];
            if (!m.isDestroyed()) {
                setCachedGltf(m, this);
            }
        }
        this.modelsToLoad = undefined;
        this.ready = true;
    };

    function containsGltfMagic(uint8Array) {
        var magic = Cesium.getMagic(uint8Array);
        return magic === 'glTF';
    }

    //362e2b
    function getSpan(v) {
        var width = v.scene.canvas.clientWidth;
        var height = v.scene.canvas.clientHeight;

        var scene = v.scene;
        var camera = v.scene.camera;
        var globe = v.scene.globe;
        const rightDown = camera.getPickRay(new Cesium.Cartesian2(width, height));
        const leftDown = camera.getPickRay(new Cesium.Cartesian2(0, height));
        var rightDownPosition = globe.pick(rightDown, scene);
        var leftDownPosition = globe.pick(leftDown, scene);
        var rightDownCartographic = globe.ellipsoid.cartesianToCartographic(rightDownPosition);
        var leftDownCartographic = globe.ellipsoid.cartesianToCartographic(leftDownPosition);
        var diffLon = Cesium.Math.toDegrees(rightDownCartographic.longitude) - Cesium.Math.toDegrees(leftDownCartographic.longitude);
        return diffLon / 100;
    }

    /**
     * 模型编辑类构造函数
     * @param cesiumViewer Cesium viewer
     * @param options 设置
     * @constructor
     */
    function ModelEdit(cesiumViewer, options) {
        options = this._options = defaultValue(options, defined(Object.freeze) ? Object.freeze({}) : {
            change: function () {
            }
        });
        if (!defined(cesiumViewer)) {
            throw new DeveloperError('Cesium.Viewer is required');
        }
        // this._modelStore = {};
        this._viewer = cesiumViewer;
        this._lon = 117.0;
        this._lat = 39.0;
        this._alti = 10.0;
        this._heading = 0;
        this._pitch = 0;
        this._roll = 0;
        this._scale = 1.0;
        this._converter = Cesium.Transforms.eastNorthUpToFixedFrame;//坐标转换器
        this._model = null;//当前选择模型
        this._modelId = '';//模型ID
        this._dragMoveEnable = false;//是否可以拖拽移动。总控
        this._dragging = false;//拖拽过程中
        this._dragOffset = {x: 0, y: 0};//鼠标选择物体便宜物体中心点距离
        this._keyBoardMove = false;//是否使用键盘w/s/a/d键控制
        this._handler = new Cesium.ScreenSpaceEventHandler(this._viewer.canvas);
        this._dragMoveTarget = null;//拖拽目标
        this._referenceFrame = null;//坐标系
        this._change = options.change;//模型参数变化触发回掉函数
        this._cache = [];//缓冲记录，在模型加载过程中记录排队加载的模型
        //添加新模型操作
        this._addDragModel = false;//添加新模型鼠标拖拽状态
        this._addModelParam = null;//所要添加的新模型参数
//        this._addModelTrace = cesiumViewer.entities.add({
//            show: false,
//            position: Cesium.Cartesian3.fromDegrees(117.0, 39.0, 10),
//            box: {
//                dimensions: new Cesium.Cartesian3(50.0, 50.0, 0),
//                material: new Cesium.Color(0 / 255, 255 / 255, 255 / 255, 0.3)
//            }
//        });
        this._addModelTrace = cesiumViewer.scene.primitives.add(new Cesium.Primitive({
        	show: false,
            geometryInstances: new Cesium.GeometryInstance({
                geometry: new Cesium.RectangleGeometry({
                    rectangle: Cesium.Rectangle.fromDegrees(-120.0, 20.0, -60.0, 40.0),
                    vertexFormat: Cesium.EllipsoidSurfaceAppearance.VERTEX_FORMAT
                })
            }),
            appearance : new Cesium.EllipsoidSurfaceAppearance({
                aboveGround : false,
                material: Cesium.Material.fromType('Color', {
                    color: new Cesium.Color(0 / 255, 255 / 255, 255 / 255, 0.3)
                })
            })
        }));//添加新模型的参考位置

        var _this = this;

        var deltaRadians = 1.0;
        document.addEventListener('keydown', function (e) {//键盘事件
            if (this._addDragModel) return;
            if (this._dragMoveEnable && defined(this._model) && this._model instanceof Cesium.Model) {
                switch (e.keyCode) {
                    case 40:
                        // pitch down
                        this._pitch -= deltaRadians;
                        if (this._pitch < -360) {
                            this._pitch += 360;
                        }
                        this.update();
                        break;
                    case 38:
                        // pitch up
                        this._pitch += deltaRadians;
                        if (this._pitch > 360) {
                            this._pitch -= 360;
                        }
                        this.update();
                        break;
                    case 39:
                        if (e.shiftKey) {
                            // roll right
                            this._roll += deltaRadians;
                            if (this._roll > 360) {
                                this._roll -= 360;
                            }
                        } else {
                            // turn right
                            this._heading += deltaRadians;
                            if (this._heading > 360) {
                                this._heading -= 360;
                            }
                        }
                        this.update();
                        break;
                    case 37:
                        if (e.shiftKey) {
                            // roll left until
                            this._roll -= deltaRadians;
                            if (this._roll < 0.0) {
                                this._roll += 360;
                            }
                        } else {
                            // turn left
                            this._heading -= deltaRadians;
                            if (this._heading < 0.0) {
                                this._heading += 360;
                            }
                        }
                        this.update();
                        break;
                    case 87: //W
                        if (this._keyBoardMove) {
                            this.setLatitude(this._lat + getSpan(this._viewer));
                        }
                        break;
                    case 83: //S
                        if (this._keyBoardMove) {
                            this.setLatitude(this._lat - getSpan(this._viewer));
                        }
                        break;
                    case 65: //A
                        if (this._keyBoardMove) {
                            this.setLongitude(this._lon - getSpan(this._viewer));
                        }
                        break;
                    case 68: //D
                        if (this._keyBoardMove) {
                            this.setLongitude(this._lon + getSpan(this._viewer));
                        }
                        break;
                    default:
                }
            }
        }.bind(this));

        this._handler.setInputAction(function (click) {//鼠标右键
            // if (options.hasOwnProperty('popup') && defined(options.popup)) {
            //     options.popup(click.position);
            // }
        }, Cesium.ScreenSpaceEventType.RIGHT_CLICK);
        this._handler.setInputAction(function (click) {//鼠标左键按下
            var pickedObject = _this._viewer.scene.pick(click.position);
            if (_this._addDragModel) {//如果是在添加新模型鼠标移动状态
                //执行添加新模型
                var arrowP = _this._viewer.camera.pickEllipsoid(click.position);
                if (defined(arrowP)) {
                    var arrowCarto = Cesium.Cartographic.fromCartesian(arrowP);
                    var lon = Cesium.Math.toDegrees(arrowCarto.longitude);
                    var lat = Cesium.Math.toDegrees(arrowCarto.latitude);
                    var modelPosition = {
                        lon: lon,
                        lat: lat,
                    };
                    //modelSource, fileId, position, completed
                    _this.loadModel(_this._addModelParam.url, _this._addModelParam.id, modelPosition, function (model) {
                        _this._addDragModel = false;
                        _this._addModelTrace.show = false;
                        if (defined(_this._addModelParam.completed)) _this._addModelParam.completed(model);
                    });
                }

                return;
            }
            if (_this._dragMoveEnable && defined(pickedObject) && pickedObject.primitive instanceof Cesium.Model) {//编辑模型状态
//            	console.log('model')
                if (!defined(pickedObject.primitive.setting)) {//没有属性setting，该模型不可编辑
                    return;
                }
                _this._model = pickedObject.primitive;
                _this.setModelSet(_this._model.setting);
                _this._dragging = true;
                _this._viewer.scene.screenSpaceCameraController.enableRotate = false;
                var arrowPosition = _this._viewer.camera.pickEllipsoid(click.position);
                if (defined(arrowPosition)) {
                    var arrowCartographic = Cesium.Cartographic.fromCartesian(arrowPosition);
                    var arrowLongitude = Cesium.Math.toDegrees(arrowCartographic.longitude);
                    var arrowLatitude = Cesium.Math.toDegrees(arrowCartographic.latitude);

                    // var center = _this._model.boundingSphere ? _this._model.boundingSphere.center : _this._model._boundingSphere.center;
                    // var centerPosition =  Cesium.Matrix4.multiplyByPoint(_this._model.modelMatrix, center, new Cesium.Cartesian3());
                    // var centerCartographic = Cesium.Cartographic.fromCartesian(centerPosition);
                    // var centerLongitude = Number(Cesium.Math.toDegrees(centerCartographic.longitude));
                    // var centerLatitude = Number(Cesium.Math.toDegrees(centerCartographic.latitude));
                    _this._dragOffset.x = Number(arrowLongitude - _this._lon);
                    _this._dragOffset.y = Number(arrowLatitude - _this._lat);
                }
            }
        }, Cesium.ScreenSpaceEventType.LEFT_DOWN);
        this._handler.setInputAction(function (movement) {//鼠标移动
            if (_this._addDragModel) {//如果是在添加新模型鼠标移动状态
                var position = _this._viewer.camera.pickEllipsoid(movement.endPosition);
//                _this._addModelTrace.position = position;
                var hpRoll = new Cesium.HeadingPitchRoll(0, 0,0);
                Cesium.Transforms.headingPitchRollToFixedFrame(position, hpRoll, Cesium.Ellipsoid.WGS84, this._converter,  _this._addModelTrace.modelMatrix);
                return;
            }
            if (!defined(_this._model)) return;
            if (_this._dragMoveEnable && _this._dragging && defined(_this._model)) {//编辑模型状态
                var position = _this._viewer.camera.pickEllipsoid(movement.endPosition);
                if (defined(position)) {
                    var cartographic = Cesium.Cartographic.fromCartesian(position);
                    var longitudeString = Cesium.Math.toDegrees(cartographic.longitude);
                    var latitudeString = Cesium.Math.toDegrees(cartographic.latitude);
                    _this.setLongitude(Number(longitudeString) - _this._dragOffset.x);
                    _this.setLatitude(Number(latitudeString) - _this._dragOffset.y);
                }
            }
            var pickedObject = _this._viewer.scene.pick(movement.endPosition);
            if (_this._dragMoveEnable && defined(pickedObject) && pickedObject.primitive === _this._model) {
                _this._model.silhouetteSize = 2;
            }
            else if (defined(_this._model)) {
                _this._model.silhouetteSize = 0;
            }
        }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
        this._handler.setInputAction(function (click) {//鼠标左键弹起
            _this._dragging = false;
            var pickedObject = _this._viewer.scene.pick(click.position);
            if (_this._dragMoveEnable && defined(pickedObject) && pickedObject.primitive === _this._model) {
                var position = _this._viewer.camera.pickEllipsoid(click.position);
                if (defined(position)) {
                    var cartographic = Cesium.Cartographic.fromCartesian(position);
                    var longitudeString = Cesium.Math.toDegrees(cartographic.longitude);
                    var latitudeString = Cesium.Math.toDegrees(cartographic.latitude);
                    _this.setLongitude(Number(longitudeString) - _this._dragOffset.x);
                    _this.setLatitude(Number(latitudeString) - _this._dragOffset.y);

                    _this.lookAtModel(false)
                }

            }
            _this._viewer.scene.screenSpaceCameraController.enableRotate = true;
        }, Cesium.ScreenSpaceEventType.LEFT_UP);
    }

    ModelEdit.prototype.loadModel = function (modelSource, fileId, setting, completed, attributes, dataBag) {
        if (defined(this._model) && !this._model.ready) {
            this._cache.push({
                url: modelSource,
                id: fileId,
                setting: setting,
                completed: completed,
                attributes: attributes,
                dataBag: dataBag
            });
            return;
        }
        var _this = this;
        //数据复位
        // if (defined(this._model) && this._viewer.scene.primitives.contains(this._model)) {
        //     this._viewer.scene.primitives.remove(this._model);
        //     this._model = null;
        // }

        this._lon = 117.0;
        this._lat = 39.0;
        this._alti = 10.0;
        this._heading = 0;
        this._pitch = 0;
        this._roll = 0;
        this._scale = 1.0;
        if(defined(setting)){
        	this._lon = setting.position.x;
            this._lat = setting.position.y;
            this._alti = setting.position.h;
            this._heading = setting.hpr.heading;
            this._pitch = setting.hpr.pitch;
            this._roll = setting.hpr.roll;
            this._scale = setting.scale;
        }

        // var modelid = Object.keys(this._modelStore).length;
        //记录名称
        this._modelId = fileId || new Date().getTime();
        //计算位置和姿态
        var origin = Cesium.Cartesian3.fromDegrees(this._lon, this._lat, this._alti);
        var modelMatrix = this._converter(origin);

        //设置坐标轴初始值
        if (defined(this._referenceFrame)) {
            this._referenceFrame.modelMatrix = modelMatrix;
            this._referenceFrame.width = 5;
        }

        if (typeof modelSource === 'string') {
            var mPrimitive = this._viewer.scene.primitives.add(Cesium.Model.fromGltf({
                id: this._modelId,
                url: modelSource,
            }));

            mPrimitive.readyPromise.then(function (model) {
                // 计算模型位置并缩放到模型
                var origin = Cesium.Cartesian3.fromDegrees(_this._lon, _this._lat, _this._alti);
                model.scale = _this._scale;
//                var modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(origin);
//                model.modelMatrix = modelMatrix;
                var hpRoll = new Cesium.HeadingPitchRoll(Cesium.Math.toRadians(_this._heading), Cesium.Math.toRadians(_this._pitch), Cesium.Math.toRadians(_this._roll));
                Cesium.Transforms.headingPitchRollToFixedFrame(origin, hpRoll, Cesium.Ellipsoid.WGS84, _this._converter, model.modelMatrix);

                _this.updateReference();
//                _this.setCamera();
                if (typeof _this._change === 'function') {
                    _this._change(_this.getModelSet());
                }
                if(defined(attributes)){
                	model.attributes = attributes;
                }
                if(defined(dataBag)){
                	model.dataBag = dataBag;
                }
                if (defined(completed)) {
                    completed(model);
                }
                if (_this._cache.length > 0) {
                    var param = _this._cache.splice(0, 1)[0];
                    _this.loadModel(param.url, param.id, param.setting, param.completed, param.attributes, param.dataBag);
                }
            });
            this._model = mPrimitive;
            this._model.setting = this.getModelSet();
        }
        else {
            //创建模型对象
            var model = new Cesium.Model({
                id: this._modelId,
                scale: this._scale,
                modelMatrix: modelMatrix
            });
            //载入模型二进制数据
            var buffer = new Uint8Array(modelSource);
            var cachedGltf = new CachedGltf({
                ready: false
            });
            cachedGltf.count = 1;
            cachedGltf.modelsToLoad.push(model);
            setCachedGltf(model, cachedGltf);
            if (containsGltfMagic(buffer)) {
                // Load binary glTF
                var parsedGltf = Cesium.parseBinaryGltf(buffer);
                // KHR_binary_glTF is from the beginning of the binary section
                cachedGltf.makeReady(parsedGltf, buffer);
            } else {
                // Load text (JSON) glTF
                var json = Cesium.getStringFromTypedArray(buffer);
                cachedGltf.makeReady(JSON.parse(json));
            }

            //创建Primitive对象
            var modelPrimitive = this._viewer.scene.primitives.add(model);
            modelPrimitive.readyPromise.then(function (model) {
                // 计算模型位置并缩放到模型
                // var r = model._boundingSphere.radius;
                // var center = new Cesium.Cartesian3();
                // Cesium.Matrix4.multiplyByPoint(model.modelMatrix, model._boundingSphere.center, center);
                var origin = Cesium.Cartesian3.fromDegrees(_this._lon, _this._lat, _this._alti);
                model.scale = _this._scale;
//              var modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(origin);
//              model.modelMatrix = modelMatrix;
              var hpRoll = new Cesium.HeadingPitchRoll(Cesium.Math.toRadians(_this._heading), Cesium.Math.toRadians(_this._pitch), Cesium.Math.toRadians(_this._roll));
              Cesium.Transforms.headingPitchRollToFixedFrame(origin, hpRoll, Cesium.Ellipsoid.WGS84, _this._converter, model.modelMatrix);

                _this.updateReference();
//                _this.setCamera();
                if (typeof _this._change === 'function') {
                    _this._change(_this.getModelSet());
                }
                if(defined(attributes)){
                	model.attributes = attributes;
                }
                if(defined(dataBag)){
                	model.dataBag = dataBag;
                }
                if (defined(completed)) {
                    completed(model);
                }
                if (_this._cache.length > 0) {
                    var param = _this._cache.splice(0, 1);
                    _this.loadModel(param.url, param.id, param.position, param.completed, param.attributes, param.dataBag);
                }
            });

            this._model = modelPrimitive;
            this._model.setting = this.getModelSet();
        }

        return this._model;
    };

    ModelEdit.prototype.setModel = function (modelId, model, setting) {
        if (defined(model)) {//设置模型及模型参数
            this._modelId = modelId;
            this._model = model;

            setting = setting || this.getModelSet();

            this._lon = setting.position.x;
            this._lat = setting.position.y;
            this._alti = setting.position.h;
            this._heading = setting.hpr.heading;
            this._pitch = setting.hpr.pitch;
            this._roll = setting.hpr.roll;
            this._scale = setting.scale;

            this._model.setting = this.getModelSet();

            this.update();
            this.updateReference();
//            this.setCamera();
        }
    };

    ModelEdit.prototype.setEnable = function (t) {
        this._dragMoveEnable = t;
//        if (t) {
//            this.setAltitude(0);
//        }
        if (t && !defined(this._referenceFrame)) {
            this._referenceFrame = this._viewer.scene.primitives.add(new Cesium.DebugModelMatrixPrimitive({}));
        }
        else if (!t && defined(this._referenceFrame)) {
            this._viewer.scene.primitives.remove(this._referenceFrame);
            this._referenceFrame = null;
        }
    };

    ModelEdit.prototype.setKeyboard = function (t) {
        this._keyBoardMove = t;
    };

    ModelEdit.prototype.setCamera = function () {
        //计算位置和姿态
        var r = this._model.boundingSphere ? this._model.boundingSphere.radius : this._model._boundingSphere.radius;
        var origin = Cesium.Cartesian3.fromDegrees(this._lon, this._lat, this._alti);
        // var heading = Cesium.Math.toRadians(0);
        // var pitch = Cesium.Math.toRadians(-90);
        var hpRange = new Cesium.HeadingPitchRange();
        hpRange.heading = this._viewer.camera.heading;
        hpRange.pitch = this._viewer.camera.pitch;
        hpRange.range = r * 5.0;
        if (!this._dragging) {
            this._viewer.camera.lookAt(origin, hpRange);
            this._viewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY);
        }
    };

    ModelEdit.prototype.lookAtModel = function (t) {
        if (t) {
            this.setCamera();
        }
        else {
            this._viewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY);
        }
    };

    ModelEdit.prototype.addDragModel = function (param) {
        this._addDragModel = true;
        this._addModelTrace.show = true;
        this._addModelParam = param;
    };

    ModelEdit.prototype.cancelAddDragModel = function () {
        this._addDragModel = false;
        this._addModelTrace.show = false;
    }

    ModelEdit.prototype.update = function () {
        if (!defined(this._model)) return;

        this._model.scale = this._scale;

        var position = Cesium.Cartesian3.fromDegrees(this._lon, this._lat, this._alti);
        var hpRoll = new Cesium.HeadingPitchRoll(Cesium.Math.toRadians(this._heading), Cesium.Math.toRadians(this._pitch), Cesium.Math.toRadians(this._roll));
        Cesium.Transforms.headingPitchRollToFixedFrame(position, hpRoll, Cesium.Ellipsoid.WGS84, this._converter, this._model.modelMatrix);

        this._model.setting = this.getModelSet();
        if (typeof this._change === 'function') {
            this._change(this.getModelSet());
        }
    };

    ModelEdit.prototype.updateReference = function () {
        if (!defined(this._model) || !defined(this._referenceFrame)) return;
        //计算位置和姿态
        var r = this._model.boundingSphere ? this._model.boundingSphere.radius : this._model._boundingSphere.radius;
        var origin = Cesium.Cartesian3.fromDegrees(this._lon, this._lat, this._alti);
        var modelMatrix = this._converter(origin);
        this._referenceFrame.modelMatrix = modelMatrix;
        // 根据模型大小重新更新坐标轴大小
        var rL = r * 2;
        this._referenceFrame.length = rL;
    };

    ModelEdit.prototype.setHeading = function (heading) {
        this._heading = heading;
        this.update();
    };

    ModelEdit.prototype.setPitch = function (pitch) {
        this._pitch = pitch;
        this.update();
    };

    ModelEdit.prototype.setRoll = function (roll) {
        this._roll = roll;
        this.update();
    };

    ModelEdit.prototype.setScale = function (scale) {
        var rL = this._referenceFrame.length * scale / this._scale;
        this._referenceFrame.length = rL;
        this._scale = scale;
        this.update();
    };

    ModelEdit.prototype.setLongitude = function (lon) {
        this._lon = lon;
        this.update();
        this.updateReference();
    };

    ModelEdit.prototype.setLatitude = function (lat) {
        this._lat = lat;
        this.update();
        this.updateReference();
    };

    ModelEdit.prototype.setAltitude = function (alti) {
        this._alti = alti;
        this.update();
        this.updateReference();
    };

    ModelEdit.prototype.getModelSet = function () {
        return {
            position: {
                x: this._lon,
                y: this._lat,
                h: this._alti
            },
            scale: this._scale,
            hpr: {
                heading: this._heading,
                pitch: this._pitch,
                roll: this._roll
            }
        };
    };

    ModelEdit.prototype.setModelSet = function (setting, isUpdate) {
        if (!defined(setting)) {
            return;
        }
        this._lon = setting.position.x;
        this._lat = setting.position.y;
        this._alti = setting.position.h;
        this._heading = setting.hpr.heading;
        this._pitch = setting.hpr.pitch;
        this._roll = setting.hpr.roll;
        this._scale = setting.scale;
        isUpdate = isUpdate === undefined ? true : isUpdate;
        if (isUpdate) {
            this.update();
            this.updateReference();
        }
    };

    ModelEdit.prototype.getModel = function () {
        // if (defined(this._model) && this._viewer.scene.primitives.contains(this._model)) {
        //     this._viewer.scene.primitives.remove(this._model);
        //     this._model = null;
        // }
        return this._model;
    };

    ModelEdit.prototype.getId = function () {
        // if (defined(this._model) && this._viewer.scene.primitives.contains(this._model)) {
        //     this._viewer.scene.primitives.remove(this._model);
        //     this._model = null;
        // }
        return this._modelId;
    };

    ModelEdit.prototype.removeModel = function () {
        // var model = this._modelStore[id];
        // if (defined(model) && this._viewer.scene.primitives.contains(model)) {
        //     this._viewer.scene.primitives.remove(model);
        //     if(model.id === this._model.id){
        //         this._model = null;
        //     }
        //     delete this._modelStore[id];
        // }
        if (defined(this._model) && this._viewer.scene.primitives.contains(this._model)) {
            this._viewer.scene.primitives.remove(this._model);
            this._model = null;
            this._modelname = '';
            this._modelId = '';
        }
    };

    window.ModelEdit = ModelEdit;
})();